package cn.fantasy.jdbc;

import java.sql.*;

/**
 * 使用PreparedStatement
 * @author zhangliang
 */
public class JavaJdbcNew {
    private static String username;
    private static String password;
    private static String driver;
    private static String jdbcurl;


    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;

        JdbcUtil util = new JdbcUtil();
        try {
            conn = util.getConnection();
            pstmt = conn.prepareStatement("select * from admin");
            rs = pstmt.executeQuery();
            while (rs.next()) {
                System.out.println(rs.getInt(1));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                util.CloseConnection(conn, pstmt, rs);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
